﻿using System;
using System.Data;

using Wicresoft.Common;

namespace Wicresoft.JDPostBoard.Entity
{
    [Table("MeetingRooms", "ID", "JDPB.ConnectionString")]
    public class MeetingRooms : Info
    {
        #region SQL column name consts
        public const string SQLCOL_ID = "ID";
        public const string SQLCOL_ROOMTYPE = "RoomType";
        public const string SQLCOL_ROOMNAME = "RoomName";
        public const string SQLCOL_LOCATION = "Location";
        public const string SQLCOL_SEATSCOUNT = "SeatsCount";
        public const string SQLCOL_PICTURE = "Picture";
        public const string SQLCOL_GROUPID = "GroupID";
        public const string SQLCOL_GROUPNAME = "GroupName";
        public const string SQLCOL_CONSERVATOR = "Conservator";
        public const string SQLCOL_CONSERVATORNAME = "ConservatorName";
        public const string SQLCOL_DESCRIPTION = "Description";
        public const string SQLCOL_FLAG = "Flag";
        public const string SQLCOL_BACKNVARCHAR = "BackNvarchar";
        public const string SQLCOL_BACKNVARCHAR1 = "BackNvarchar1";
        public const string SQLCOL_BACKINT = "BackInt";
        #endregion


        #region Contructors
        /// <summary>
        /// Construct empty entity
        /// </summary>
        public MeetingRooms() { }

        /// <summary>
        /// Construct entity by primary key, other fields will be assigned by 
        /// "Load" method.
        /// </summary>
        public MeetingRooms(int ID)
        {
            this.ID = ID;
        }
        #endregion

        public override void Init(DataRow row)
        {
            ID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_ID]);
            RoomType = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_ROOMTYPE]);
            RoomName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_ROOMNAME]);
            Location = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_LOCATION]);
            SeatsCount = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_SEATSCOUNT]);
            Picture = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_PICTURE]);
            GroupID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_GROUPID]);
            GroupName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_GROUPNAME]);
            Conservator = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_CONSERVATOR]);
            ConservatorName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_CONSERVATORNAME]);
            Description = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_DESCRIPTION]);
            Flag = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_FLAG]);
            BackNvarchar = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_BACKNVARCHAR]);
            BackNvarchar1 = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_BACKNVARCHAR1]);
            BackInt = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_BACKINT]);
        }

        #region Properties
        #region Property <int> ID
        [Property("ID", 4, SqlDbType.Int, true, true)]
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }
        private int _ID = int.MinValue;
        #endregion

        #region Property <int> RoomType
        [Property("RoomType", 4, SqlDbType.Int, false, false)]
        public int RoomType
        {
            get { return _RoomType; }
            set { _RoomType = value; }
        }
        private int _RoomType = int.MinValue;
        #endregion

        #region Property <string> RoomName
        [Property("RoomName", 100, SqlDbType.NVarChar, false, false)]
        public string RoomName
        {
            get { return _RoomName; }
            set { _RoomName = value; }
        }
        private string _RoomName = null;
        #endregion

        #region Property <string> Location
        [Property("Location", 200, SqlDbType.NVarChar, false, false)]
        public string Location
        {
            get { return _Location; }
            set { _Location = value; }
        }
        private string _Location = null;
        #endregion

        #region Property <int> SeatsCount
        [Property("SeatsCount", 4, SqlDbType.Int, false, false)]
        public int SeatsCount
        {
            get { return _SeatsCount; }
            set { _SeatsCount = value; }
        }
        private int _SeatsCount = int.MinValue;
        #endregion

        #region Property <string> Picture
        [Property("Picture", 100, SqlDbType.NVarChar, false, false)]
        public string Picture
        {
            get { return _Picture; }
            set { _Picture = value; }
        }
        private string _Picture = null;
        #endregion

        #region Property <Guid> GroupID
        [Property("GroupID", 16, SqlDbType.UniqueIdentifier, false, false)]
        public Guid GroupID
        {
            get { return _GroupID; }
            set { _GroupID = value; }
        }
        private Guid _GroupID = Guid.Empty;
        #endregion

        #region Property <string> GroupName
        [Property("GroupName", 200, SqlDbType.NVarChar, false, false)]
        public string GroupName
        {
            get { return _GroupName; }
            set { _GroupName = value; }
        }
        private string _GroupName = null;
        #endregion

        #region Property <string> Conservator
        [Property("Conservator", 40, SqlDbType.NVarChar, false, false)]
        public string Conservator
        {
            get { return _Conservator; }
            set { _Conservator = value; }
        }
        private string _Conservator = null;
        #endregion

        #region Property <string> ConservatorName
        [Property("ConservatorName", 100, SqlDbType.NVarChar, false, false)]
        public string ConservatorName
        {
            get { return _ConservatorName; }
            set { _ConservatorName = value; }
        }
        private string _ConservatorName = null;
        #endregion

        #region Property <string> Description
        [Property("Description", 1000, SqlDbType.NVarChar, false, false)]
        public string Description
        {
            get { return _Description; }
            set { _Description = value; }
        }
        private string _Description = null;
        #endregion

        #region Property <string> Flag
        [Property("Flag", 1, SqlDbType.Char, false, false)]
        public string Flag
        {
            get { return _Flag; }
            set { _Flag = value; }
        }
        private string _Flag = null;
        #endregion

        #region Property <string> BackNvarchar
        [Property("BackNvarchar", 100, SqlDbType.NVarChar, false, false)]
        public string BackNvarchar
        {
            get { return _BackNvarchar; }
            set { _BackNvarchar = value; }
        }
        private string _BackNvarchar = null;
        #endregion

        #region Property <string> BackNvarchar1
        [Property("BackNvarchar1", 100, SqlDbType.NVarChar, false, false)]
        public string BackNvarchar1
        {
            get { return _BackNvarchar1; }
            set { _BackNvarchar1 = value; }
        }
        private string _BackNvarchar1 = null;
        #endregion

        #region Property <int> BackInt
        [Property("BackInt", 4, SqlDbType.Int, false, false)]
        public int BackInt
        {
            get { return _BackInt; }
            set { _BackInt = value; }
        }
        private int _BackInt = int.MinValue;
        #endregion
        #endregion


        public bool LoadByIdentity(int ID)
        {
            return DataAccess.SelectByIdentity(this, Convert.ToInt64(ID));
        }


        public bool DeleteByIdentity()
        {
            return DataAccess.DeleteByIdentity(this);
        }
    }
}
